using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MimeCloud.AssetManagement.Business.Interface;
using MimeCloud.AssetManagement.ProviderServices.Data;
using MimeCloud.AssetManagement.ProviderServices;
using MimeCloud.Foundations.ObjectManagement;

namespace MimeCloud.AssetManagement.DataProvider.Sql
{
    public class Searcher : IAssetSearcher
    {
        private AssetManagerDataContext context
        {
            get
            {
                return Singleton<AssetManagerDataContext>.UserContextScoped;
            }
        }

        public IList<IAssetContent> ContentFromFullPath(IRepository repo, string assetContentPath)
        {
                //var contentMatch = from cont in context.Search_GetByPathAndRepository(assetContentPath, repo.ID)
                //                   select cont.AssetContent_IDPK;

                //var content =
                //    contentMatch.Select(s => AssetManagerConfig.GetAssetReaderProvider().GetAssetContentByID(s)).ToList();
                //if (content==null)
                //    return new List<IAssetContent>();
                //else
                //{
                //    return content;
                //}
            throw new NotImplementedException();
        }

        public IList<IAsset> LatestAssets(int count)
        {
                var latest = from ast in context.Assets orderby ast.CreationDate descending select ast;
                return latest.Take(count).Cast<IAsset>().ToList();
        }
    }
}
